import java.time.LocalDate

/**
 * Author atguigu
 * Date 2020/11/13 10:30
 */
object ImplicitDemo1 {
    def main(args: Array[String]): Unit = {
        val ago = "ago"
        val later = "later"
        val a = 2 days ago // 2.days(ago)
        println(a)
        println(3 days later)
    }
    
    implicit class RichInt(day: Int) {
        def days(when: String) = {
            when match {
                case "ago" =>
                    LocalDate.now().plusDays(-day).toString
                case "later" =>
                    LocalDate.now().plusDays(day).toString
            }
        }
    }
    
}
